import std/math
proc rgb(r: int, g: int, b: int) =
  stdout.write "\x1b[38;2;" & $r & ";" & $g & ";" & $b & "m"
proc rainbow(freq: float, i: float) =
  let r: int = (sin(freq*i) * 127 + 128).int
  let g: int = (sin(freq*i + 2*Pi/3) * 127 + 128).int
  let b: int = (sin(freq*i + 4*Pi/3) * 127 + 128).int
  rgb(r, g, b)

var i: int = 0
var n: int = 0
while true:
  try:
    let c = readChar(stdin)
    if c == '\n':
      n += 1
      i = 0
    rainbow(0.1, i.float+ n.float/3.0)
    stdout.write c
    i += 1
  except:
    stdout.write "\x1b[0m"
    quit 0
